import os
import shutil
import sys
import zipfile
import os


if __name__ == '__main__':
    mode = sys.argv[1]

    base_path = 'out/shennong.dist'
    # 拷贝browse-config
    if mode == 'test':
        shutil.rmtree(f'{base_path}/account', ignore_errors=True)
        shutil.copytree('account', f'{base_path}/account')
    else:
        shutil.rmtree(f'{base_path}/account', ignore_errors=True)
        os.makedirs(f'{base_path}/account')

    # 拷贝Firefox
    shutil.rmtree(f'{base_path}/firefox', ignore_errors=True)
    shutil.copytree('firefox', f'{base_path}/firefox')

    # 拷贝setting
    shutil.copyfile('setting.ini', f'{base_path}/setting.ini')

    # 拷贝default
    shutil.copyfile('default_install.ini', f'{base_path}/default.ini')

    # 拷贝favicon.ico
    shutil.copyfile('favicon.ico', f'{base_path}/favicon.ico')

    # 拷贝geckodriver
    shutil.copyfile('geckodriver.exe', f'{base_path}/geckodriver.exe')

    # comment.csv
    shutil.copyfile('comment.csv', f'{base_path}/comment.csv')

    # 拷贝selenium
    shutil.rmtree(f'{base_path}/selenium', ignore_errors=True)
    shutil.copytree('selenium', f'{base_path}/selenium')

    # 创建log文件夹
    try:
        shutil.rmtree(f'{base_path}/log')
    except:
        pass
    os.makedirs(f'{base_path}/log')

